<?php
class Config extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableDefinition('immo_config');
        $this->hasColum('module', 'string', '250');
        $this->hasColum('setting', 'string', '10000');
    }
    
    /**
    * Recupere les parametres
    * 
    * @param mixed $caching
    */
    public function getAll($caching = false)
    {
        $settingArray = array();
        
        if($caching == true)
        {
            if( !$settingArray = $GLOBALS['cache']->get('settings'))
            {
                $q = Doctrine_Query::create()
                    ->select('setting', 'auteur')
                    ->from('immo_config')
                    ->execute();
                    
                foreach($q as $setting)
                {
                    $settingArray['' . $setting->module . ''] = $setting->setting;   
                }   
                
                $GLOBALS['cache']->save($settingArray);
                
            }   
        } 
        else
        {
            $q = Doctrine_Query::create()
                    ->select('setting', 'auteur')
                    ->from('immo_config')
                    ->excute();
                    
                foreach($q as $setting)
                {
                    $settingArray['' . $setting->module . ''] = $setting->setting;   
                }    
        }
        
        return $settingArray; 
    }
}
?>
